/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.dengues.model.project.impl;

import java.util.Collection;
import org.dengues.model.project.CDCConnType;
import javax.xml.datatype.XMLGregorianCalendar;

import org.dengues.model.project.ConnPropertySetType;
import org.dengues.model.project.ProjectPackage;
import org.dengues.model.project.ProjectType;
import org.dengues.model.project.UserType;

import org.dengues.model.project.VersionMigration;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getUser <em>User</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getComment <em>Comment</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getCreateTime <em>Create Time</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getVersion <em>Version</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getConnProperties <em>Conn Properties</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getCdcConns <em>Cdc Conns</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ProjectTypeImpl#getMigrations <em>Migrations</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProjectTypeImpl extends EObjectImpl implements ProjectType {
    /**
     * The cached value of the '{@link #getUser() <em>User</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getUser()
     * @generated
     * @ordered
     */
    protected EList<UserType> user;

    /**
     * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getComment()
     * @generated
     * @ordered
     */
    protected static final String COMMENT_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getComment()
     * @generated
     * @ordered
     */
    protected String comment = COMMENT_EDEFAULT;

    /**
     * The default value of the '{@link #getCreateTime() <em>Create Time</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getCreateTime()
     * @generated
     * @ordered
     */
    protected static final String CREATE_TIME_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getCreateTime() <em>Create Time</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getCreateTime()
     * @generated
     * @ordered
     */
    protected String createTime = CREATE_TIME_EDEFAULT;

    /**
     * The default value of the '{@link #getName() <em>Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getName()
     * @generated
     * @ordered
     */
    protected static final String NAME_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getName()
     * @generated
     * @ordered
     */
    protected String name = NAME_EDEFAULT;

    /**
     * The default value of the '{@link #getVersion() <em>Version</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getVersion()
     * @generated
     * @ordered
     */
    protected static final String VERSION_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getVersion()
     * @generated
     * @ordered
     */
    protected String version = VERSION_EDEFAULT;

    /**
     * The cached value of the '{@link #getConnProperties() <em>Conn Properties</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getConnProperties()
     * @generated
     * @ordered
     */
    protected EList<ConnPropertySetType> connProperties;

    /**
     * The cached value of the '{@link #getCdcConns() <em>Cdc Conns</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getCdcConns()
     * @generated
     * @ordered
     */
    protected EList<CDCConnType> cdcConns;

    /**
     * The cached value of the '{@link #getMigrations() <em>Migrations</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getMigrations()
     * @generated
     * @ordered
     */
    protected EList<VersionMigration> migrations;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected ProjectTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return ProjectPackage.Literals.PROJECT_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<UserType> getUser() {
        if (user == null) {
            user = new EObjectContainmentEList<UserType>(UserType.class, this, ProjectPackage.PROJECT_TYPE__USER);
        }
        return user;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getComment() {
        return comment;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setComment(String newComment) {
        String oldComment = comment;
        comment = newComment;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.PROJECT_TYPE__COMMENT, oldComment, comment));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getCreateTime() {
        return createTime;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setCreateTime(String newCreateTime) {
        String oldCreateTime = createTime;
        createTime = newCreateTime;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.PROJECT_TYPE__CREATE_TIME, oldCreateTime, createTime));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getName() {
        return name;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setName(String newName) {
        String oldName = name;
        name = newName;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.PROJECT_TYPE__NAME, oldName, name));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getVersion() {
        return version;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setVersion(String newVersion) {
        String oldVersion = version;
        version = newVersion;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.PROJECT_TYPE__VERSION, oldVersion, version));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<ConnPropertySetType> getConnProperties() {
        if (connProperties == null) {
            connProperties = new EObjectContainmentEList<ConnPropertySetType>(ConnPropertySetType.class, this, ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES);
        }
        return connProperties;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<CDCConnType> getCdcConns() {
        if (cdcConns == null) {
            cdcConns = new EObjectContainmentEList<CDCConnType>(CDCConnType.class, this, ProjectPackage.PROJECT_TYPE__CDC_CONNS);
        }
        return cdcConns;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<VersionMigration> getMigrations() {
        if (migrations == null) {
            migrations = new EObjectContainmentEList<VersionMigration>(VersionMigration.class, this, ProjectPackage.PROJECT_TYPE__MIGRATIONS);
        }
        return migrations;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case ProjectPackage.PROJECT_TYPE__USER:
                return ((InternalEList<?>)getUser()).basicRemove(otherEnd, msgs);
            case ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES:
                return ((InternalEList<?>)getConnProperties()).basicRemove(otherEnd, msgs);
            case ProjectPackage.PROJECT_TYPE__CDC_CONNS:
                return ((InternalEList<?>)getCdcConns()).basicRemove(otherEnd, msgs);
            case ProjectPackage.PROJECT_TYPE__MIGRATIONS:
                return ((InternalEList<?>)getMigrations()).basicRemove(otherEnd, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case ProjectPackage.PROJECT_TYPE__USER:
                return getUser();
            case ProjectPackage.PROJECT_TYPE__COMMENT:
                return getComment();
            case ProjectPackage.PROJECT_TYPE__CREATE_TIME:
                return getCreateTime();
            case ProjectPackage.PROJECT_TYPE__NAME:
                return getName();
            case ProjectPackage.PROJECT_TYPE__VERSION:
                return getVersion();
            case ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES:
                return getConnProperties();
            case ProjectPackage.PROJECT_TYPE__CDC_CONNS:
                return getCdcConns();
            case ProjectPackage.PROJECT_TYPE__MIGRATIONS:
                return getMigrations();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @SuppressWarnings("unchecked")
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case ProjectPackage.PROJECT_TYPE__USER:
                getUser().clear();
                getUser().addAll((Collection<? extends UserType>)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__COMMENT:
                setComment((String)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__CREATE_TIME:
                setCreateTime((String)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__NAME:
                setName((String)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__VERSION:
                setVersion((String)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES:
                getConnProperties().clear();
                getConnProperties().addAll((Collection<? extends ConnPropertySetType>)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__CDC_CONNS:
                getCdcConns().clear();
                getCdcConns().addAll((Collection<? extends CDCConnType>)newValue);
                return;
            case ProjectPackage.PROJECT_TYPE__MIGRATIONS:
                getMigrations().clear();
                getMigrations().addAll((Collection<? extends VersionMigration>)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case ProjectPackage.PROJECT_TYPE__USER:
                getUser().clear();
                return;
            case ProjectPackage.PROJECT_TYPE__COMMENT:
                setComment(COMMENT_EDEFAULT);
                return;
            case ProjectPackage.PROJECT_TYPE__CREATE_TIME:
                setCreateTime(CREATE_TIME_EDEFAULT);
                return;
            case ProjectPackage.PROJECT_TYPE__NAME:
                setName(NAME_EDEFAULT);
                return;
            case ProjectPackage.PROJECT_TYPE__VERSION:
                setVersion(VERSION_EDEFAULT);
                return;
            case ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES:
                getConnProperties().clear();
                return;
            case ProjectPackage.PROJECT_TYPE__CDC_CONNS:
                getCdcConns().clear();
                return;
            case ProjectPackage.PROJECT_TYPE__MIGRATIONS:
                getMigrations().clear();
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case ProjectPackage.PROJECT_TYPE__USER:
                return user != null && !user.isEmpty();
            case ProjectPackage.PROJECT_TYPE__COMMENT:
                return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
            case ProjectPackage.PROJECT_TYPE__CREATE_TIME:
                return CREATE_TIME_EDEFAULT == null ? createTime != null : !CREATE_TIME_EDEFAULT.equals(createTime);
            case ProjectPackage.PROJECT_TYPE__NAME:
                return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
            case ProjectPackage.PROJECT_TYPE__VERSION:
                return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version);
            case ProjectPackage.PROJECT_TYPE__CONN_PROPERTIES:
                return connProperties != null && !connProperties.isEmpty();
            case ProjectPackage.PROJECT_TYPE__CDC_CONNS:
                return cdcConns != null && !cdcConns.isEmpty();
            case ProjectPackage.PROJECT_TYPE__MIGRATIONS:
                return migrations != null && !migrations.isEmpty();
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (comment: ");
        result.append(comment);
        result.append(", createTime: ");
        result.append(createTime);
        result.append(", name: ");
        result.append(name);
        result.append(", version: ");
        result.append(version);
        result.append(')');
        return result.toString();
    }

} //ProjectTypeImpl
